import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import*
testCase="DBshop010_销售管理退货处理退货"
firefox=openBrowser(urlAdmin) #调用函数打开网址
DBshopLoginAdmin(firefox)
# 2.在订单号查询框输入“1594531607860011”，点击“搜索”按钮。
DBshopEnterMenu2(firefox,'销售管理','退货管理')
from selenium.webdriver.support.select import Select
s=Select(firefox.find_element_by_xpath('//select[@name="refund_type"]'))
s.select_by_index(1)
firefox.find_element_by_xpath('//button[@class="btn btn-small btn-primary" and @type="submit"]').click()
firefox.find_element_by_link_text("处理退货").click()
firefox.find_element_by_id("refund_price").send_keys("2199")
firefox.find_element_by_id("re_refund_info").send_keys("同意")
firefox.find_element_by_xpath("//button[text()='提交处理结果']").click()
firefox=openBrowser(url)

DBshopLogin(firefox,userName,password)
firefox.find_element_by_link_text("用户中心").click()
firefox.find_element_by_link_text("退货申请").click()
firefox.find_elements_by_link_text("查看退货详情")[1].click()

try:
    zt=firefox.find_element_by_xpath("//div[@class='more']").text
    if '退款成功' in zt:
        writeLog("%s 测试通过" % testCase)

except:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
firefox.quit()